<?php 	$this->load->helper('date');
//Programer note:	ID attributes used for client-side operations. (ID follows modular '_camelCase' control naming convention).
//Name attribute is used for Posting/Data operations.	(Name follows field name from database convention) 
?>
<!DOCTYPE html>
<html>
	<head>
		<title><?php echo $title;?></title>
		<?php echo link_tag('css/ppharm_popup.css'.'?'.time());?> 
		<?php echo link_tag('css/custom-theme/jquery-ui-1.8.2.custom.css'.'?'.time());?>
		
		<link rel="stylesheet" href="<?php echo base_url();?>css/intervention_print.css<?php  echo '?'.time();?>" type="text/css" media="print" />
		<!-- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>  
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
		<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>-->
		<script type="text/javascript" src="<?php echo base_url().('/js/jquery.min.js');?>"></script>
		<script type="text/javascript" src="<?php echo base_url().('/js/jquery-ui.min.js');?>"></script>
		<script type="text/javascript" src="<?php echo base_url().('/js/jquery.validate.min.js');?>"></script>
		<script type="text/javascript" src="<?php echo base_url().('/js/common_form_functions.js').'?'.time();//TODO:  Version this once complete. Must timestamp so it will always update from cache?>"></script>
		<script type="text/javascript" src="<?php echo base_url().('/js/intervention_view.js').'?'.time();//TODO:  Version this once complete. Must timestamp so it will always update from cache?>"></script>
		<?php //Ths functions in the following javascript require some PHP coding.  They are all called from the js file intervention_view.js ?>
		<script type="text/javascript">
			<?php //This function is called from the doc ready function in intervention_view.js'?> 
			function additional_javascript_doc_ready_functions()
			{
				<?php echo isset($additional_javascript_doc_ready_functions)? $additional_javascript_doc_ready_functions : '' ; ?>
			}
		
			<?php echo isset($additional_jquery_javascript) ? $additional_jquery_javascript : '' ?>
		
			function GetDrugFrequncyRatio(drugFrequencyId)
			{
				var retVal = 0;
				switch(drugFrequencyId)
				{
			<?php foreach($drug_frequency_ratio as $key => $val):?>
			<?php echo "case $key: retVal= $val; break;"?>
			<?php endforeach;?>
				}
				return retVal;
			}
		
			function SetDrugFrequencyByRatio(drugRatio)
			{
				var retVal = 0;
				switch(drugRatio)
				{
			<?php foreach($drug_frequency_ratio as $key => $val):?>
			<?php echo "case \"$val\": retVal= $key; break;"?>
			<?php endforeach;?>
				}
				return retVal;
			}

			function my_url()
			{
				return '<?php echo site_url(); //Needed to reference website from javascript?>';
			}
		</script>
	</head>
	<body>
	
		<div class = "ppg-logo">
			<image src="<?php echo base_url().'/images/comp_logo.jpg';?>"/>
		</div>
		<div class="facility-name">
			<span style="padding-right: 150px; font-family: Arial, 'Trebuchet MS', sans-serif; font-size: 22px;">
				<?php echo $heading;?>
			</span>
			<?php echo $user_facility_name;?>
		</div>
		<div class = "clear-class"></div>

		<?php echo validation_errors(); ?>
	
	
		<?php 
		$this->load->helper('form');
		echo form_open('intervention/'.$save_type, array('id'=>'_ciForm'));
		?>
	
		<?php	//////////////////////////////
				 //BEGIN LEFT COLUMN CONTROLS//
				 //////////////////////////////?>
		<div class = "leftcol">
	
		
	
		<?php echo form_fieldset('General Information','class = "general-info-fieldset"');?>
	
			<?php echo form_label('<u>P</u>atient ID Number:', '_patientIdNumber');?>
				<input class="uppercase" type="text" id="_patientIdNumber" accesskey="p" name = "patient_id_number" 
						 value="<?php echo set_value('patient_id_number', $patient_id_number); ?>" size="50" autocomplete="off" />
				<br class="clear" />
				 <div class="horizontal-divider"></div>
			<?php echo form_label('Intervention Date:', '_interventionDate');?>
				<input type="text" id="_interventionDate" name = "intervention_date" class="date-box editable" value="<?php echo set_value('intervention_date', $intervention_date); ?>" size="50" autocomplete="off" />
				<br class="clear" />
				<div class="horizontal-divider"></div>
			<?php echo form_label('Intervention Code:', '_interventionCode','class = "jingles"');?>
			<?php echo form_dropdown('intervention_code_id', $my_code_list, $intervention_code_id, 'id="_interventionCode" class="editable"'); //The 4th parameter is the js option?> <div id="_interventionCodeHelpDiv" class="ui-state-default ui-corner-all" style="float:left; "><span class="ui-icon ui-icon-help"></span></div>
			<br class="clear" />
			<div class="horizontal-divider"></div>
			<?php echo form_label('Comment:', '_comment');?>
			<input type="text" id = "_comment" name="comment" class="comment-box" value="<?php echo set_value('Comment', $comment); ?>" size="50" autocomplete="off" />
			<br class="clear" />
			<div class="horizontal-divider"></div>
			<?php echo form_label('Status:', '_status');?>
			<?php echo form_dropdown('status', $status_list, $status, 'id="_status" class="editable"'); //The 4th parameter is the js option?><div id="_statusHelpDiv" class="ui-state-default ui-corner-all" style="float:left; "><span class="ui-icon ui-icon-help"></span></div>
			<br class="clear" />
			<div class="horizontal-divider"></div>
			<?php echo form_label('Physician:', '_physician');?>
			<?php echo form_dropdown('physician_id', $physician_list, $physician_id, 'id = "_physician" class="editable"'); //The 4th parameter is the js option?>
			<br class="clear" />
			<div class="horizontal-divider"></div>
			<?php echo form_label('Unit/Patient Location:', '_unitPatientLocationId');?>
			<?php echo form_dropdown('unit_patient_location_id', $unit_patient_location_list, $unit_patient_location_id, 'id = "_unitPatientLocationId" class="editable"'); //The 4th parameter is the js option?>
			<br class="clear" />
			<div class="horizontal-divider"></div>
			<?php echo form_label('Pharmacist:', '_pharmacist');?>
			<?php echo form_dropdown('pharmacist_id', $pharmacist_list, $pharmacist_id, 'id = "_pharmacist" class="editable"'); //The 4th parameter is the js option?>
			
			
		<?php echo form_fieldset_close(); //General Information Fieldset ?>
		<div class="horizontal-divider"></div>
		
		<?php echo form_fieldset('Ordered Drug','class = "drug-fieldset"');?>
			
			<div class = "indent-drug-line">
				<?php echo form_label('Drug Name:', '_orderedDrugText');?>
				<input type="text" id="_orderedDrugText" name = "ordered_drug_text" class = "drug-textbox" value="<?php echo set_value('OrderedDrugText', $ordered_drug_text); ?>" size="250" autocomplete="off"/>
			</div>
			 <div class="horizontal-divider"></div>
			 <table class = "drug-table">
				<tr>
				 <td>
					<?php echo form_label('Unit Cost:', '_orderedUnitCost');?>
				 </td>
				<td class = "filler-block"></td>
				<td>
				<?php echo form_label('Drug Frequency:', '_orderedDrugFrequencyId');?><div id="_drugfrequencyHelpDiv1" class="ui-state-default ui-corner-all" style="float:left; "><span class="ui-icon ui-icon-help"></span></div>
				</td>
				<td class = "filler-block"></td>
				<td>
					<?php echo form_label('Doses Per Day:', '_orderedDosesPerDay');?>
				</td>
				<td class = "filler-block"></td>
				<td>
					<?php echo form_label('Cost Per Day:', '_costPerDay');?>
				</td>
				<td></td>
			</tr>
			
			<tr>
				<td>
					<input type="text" id="_orderedUnitCost" name = "ordered_unit_cost" class="unit-cost" value="<?php echo set_value('OrderedUnitCost', $ordered_unit_cost); ?>" size="20" autocomplete="off"/>
				</td>
				<td class = "filler-block">X</td>
				<td>
				 <?php echo form_dropdown('ordered_drug_frequency_id', $drug_frequency_list, $ordered_drug_frequency_id, 'id="_orderedDrugFrequencyId" class="editable"'); //The 4th parameter is the js option?>
				</td>
				<td class = "filler-block">X</td>
				<td>
					<input type="text" id="_orderedDosesPerDay" name = "ordered_doses_per_day" value="<?php echo set_value('OrderedDosesPerDay', $ordered_doses_per_day); ?>" size="20" autocomplete="off"/>
				</td>
				<td class = "filler-block">=</td>
				<td>
					<input type="text" id="_orderedCostPerDay" readonly="readonly" tabindex="-1" class = "read-only-input" value="" size="20" autocomplete="off"/>
				</td>
					<td>
					<div id="_costperdayHelpDiv1" class="ui-state-default ui-corner-all" style="float:left; "><span class="ui-icon ui-icon-help"></span></div>
					</td>
				</tr>
			</table>
		<?php echo form_fieldset_close(); //Ordered Drug Fieldset ?>
		
		<div class="horizontal-divider"></div>
		
		
		<?php echo form_fieldset('Recommended Drug','class = "drug-fieldset recommended-fieldset"');?>
			
			<div class = "indent-drug-line">
			<?php echo form_label('Drug Name:', '_recommendedDrugText');?>
			<input type="text" id="_recommendedDrugText" name = "recommended_drug_text" class = "drug-textbox" value="<?php echo set_value('RecommendedDrugText', $recommended_drug_text); ?>" size="250" autocomplete="off"/>
			</div>
			
			<table class = "drug-table">
				<tr>
					<td>				
						<?php echo form_label('Unit Cost:', '_recommendedUnitCost');?>
					</td>
					<td class = "filler-block"></td>
					<td>
						<?php echo form_label('Drug Frequency:', '_recommendedDrugFrequencyId');?><div id="_drugfrequencyHelpDiv2" class="ui-state-default ui-corner-all" style="float:left; "><span class="ui-icon ui-icon-help"></span></div>
					</td>
					<td class = "filler-block"></td>
					<td>
						<?php echo form_label('Doses Per Day:', '_recommendedDosesPerDay');?>
					</td>
					<td class = "filler-block"></td>
					<td>
						<?php echo form_label('Cost Per Day:', '_costPerDay');?>
					</td>
					<td></td>
			</tr>
				
			<tr>
					<td class = "unit-cost-block">
						<input type="text" id="_recommendedUnitCost" name = "recommended_unit_cost" class="unit-cost" value="<?php echo set_value('RecommendedUnitCost', $recommended_unit_cost); ?>" size="20" autocomplete="off"/>
					</td>
					<td class = "filler-block">X</td>
					<td>
						<?php echo form_dropdown('recommended_drug_frequency_id', $drug_frequency_list, $recommended_drug_frequency_id, 'id="_recommendedDrugFrequencyId" class="editable"'); //The 4th parameter is the js option?>
					</td>
					<td class = "filler-block">X</td>
					<td>
						<input type="text" id="_recommendedDosesPerDay" name = "recommended_doses_per_day" value="<?php echo set_value('RecommendedDosesPerDay', $recommended_doses_per_day); ?>" size="20" autocomplete="off"/>
					</td>
					<td class = "filler-block">=</td>
					<td>
						<input type="text" id="_recommendedCostPerDay" readonly="readonly" tabindex="-1" class="read-only-input" value="" size="20" autocomplete="off"/>
					</td>
					<td>
					<div id="_costperdayHelpDiv2" class="ui-state-default ui-corner-all" style="float:left; "><span class="ui-icon ui-icon-help"></span></div>
					</td>
				</tr>
			</table>
		<?php echo form_fieldset_close(); //Recommended Drug Fieldset ?>
		
		<div class="navigation-bar">
			<?php echo isset($nav_bar) ? $nav_bar : '' ; ?>
		</div>
		
	
	 	</div> <?php //END LEFT COL DIV?>
		
	 
		<?php	///////////////////////////////
				 //BEGIN RIGHT COLUMN CONTROLS//
				 /////////////////////////////// ?>
		<div class = "rightcol">
		
		<?php	echo form_fieldset('Intervention Code List', 'class = "intervention-code-fieldset"');?>
		<?php echo form_dropdown('not_used__for_db_code', $my_code_list_box, -1, 'size='.count($my_code_list_box).' id="_interventionCodeListBox" tabindex="-1"'); //The 4th parameter is the js option?>
		<br class="clear" />
							 <p>(r):	risk mitigation<span id="_riskmitigationHelpDiv" class="ui-state-default ui-corner-all" style="float:right; "><span class="ui-icon ui-icon-help"></span></span></p>
		<?php echo form_fieldset_close(); //Intervention Code List Fieldset ?>
		
		
		<?php	echo form_fieldset('Tx Days','class = "tx-days-fieldset"');?>
		<table class="tx-days-table">
			<tr>
				<td>
					<?php echo form_label('Days of Tx:', '_daysOfTx');?>
				</td>
				<td>
					<input type="text" id="_daysOfTx" name="days_of_tx" class="tx-days-input" value="<?php echo set_value('days_of_tx', $days_of_tx); ?>" size="10" autocomplete="off" />
				</td>
				<td>
					<div id="_daysOfTxHelpDiv" class="ui-state-default ui-corner-all" style="margin-top: 5px; float:right; "><span class="ui-icon ui-icon-help"></span></div>
				</td>
			</tr>
			<tr>
				<td>
					<?php echo form_label('Current Tx Day:', '_currentTxDay');	?>
				</td>
				<td>
					<input type="text" id="_currentTxDay" name="current_tx_day" class="tx-days-input" value="<?php echo set_value('current_tx_day', $current_tx_day); ?>" size="10" autocomplete="off"/>
				</td>
				<td>
					<div id="_currentTxDayHelpDiv" class="ui-state-default ui-corner-all" style="margin-top: 5px; float:right; "><span class="ui-icon ui-icon-help"></span></div>
				</td>
			</tr>
		</table>			
		<?php echo form_fieldset_close(); //Tx Days Fieldset ?>

		<?php	echo form_fieldset('Calculated','class = "calculated-fieldset"');?>
		<table>
			<tr>
				<td>
					<?php echo form_label('Days Remaining:', '_daysRemaining');?>
				</td>
				<td>
					<input type="text" id="_daysRemaining" name="days_remaining" readonly="readonly" value="" size="10" autocomplete="off" tabindex="-1"/>
				</td>
				<td>
					<div id="_daysRemainingHelpDiv" class="ui-state-default ui-corner-all" style="margin-top: 5px; float:right; "><span class="ui-icon ui-icon-help"></span></div>
				</td>
			</tr>
			<tr>				
				<td>
					<?php echo form_label('Savings:', '_savings');	?>
				</td>
				<td>
					<input type="text" id="_savings" name="savings" readonly="readonly" value="<?php echo set_value('savings', ''); ?>" size="10" autocomplete="off" tabindex="-1"/><br>
				</td>
				<td>

				</td>
			</tr>
		</table>	
		<?php echo form_fieldset_close(); //Tx Days Fieldset ?>
		<br class="clear" />
	<?php 	//only show the clear form button in add mode.  Does not make sense to clear form for editing an intervention
			if ($save_type === 'save_new')
				echo '<button id="_clearForm" tabindex="-1" class="thin-button" />Clear Form</button><br>';?>
	
	<input class="normalInput" name="save" id="_save" type="submit"	value="Ok"/>
	<button name="close" id="_close" class = "close-button" />Close</button>
	<input type="button" value="Print" onClick="window.print()" />
	</div>
		<?php echo form_hidden('intervention_id', $intervention_id);?>
		<?php echo form_hidden('ordered_drug_id', $ordered_drug_id);?>
		<?php echo form_hidden('recommended_drug_id', $recommended_drug_id);?>	
		<?php echo form_hidden('ordered_default_doses_per_day', $ordered_doses_per_day);?>
		<?php echo form_hidden('recommended_default_doses_per_day', $recommended_doses_per_day);?>
		<?php echo form_hidden('patient_id', $patient_id);?>
		<?php echo form_hidden('uri',$this->uri->uri_string());?>
		 
	<?php	echo form_close(); ?>
	<div class = "clear-class"><?php //This class required to get the footer to correctly appear in IE?></div>
	<div class="footer"> 
		<?php echo form_label('Date added:', '_createdDate');?><input type="text" id="_createdDate" name = "created_date" readonly="readonly" tabindex="-1" value="<?php echo set_value('created_date', $created_date); ?>" size="50" autocomplete="off" />		
		<?php echo form_label('Last Modified:', '_modifiedDate');?><input type="text" id="_modifiedDate" name = "modified_date" readonly="readonly" tabindex="-1" value="<?php echo set_value('modified_date', $modified_date); ?>" size="50" autocomplete="off" />
	</div> 
	
	
	<?php //Start Help Messages Here?>
		<div id="status-help-dialog-message" title="Status">
			<p>
				<p>This option indicates whether the intervention was accepted, Rejected or is still Pending.</p>
				<p>This entry is important as the intervention will not be counted unless a value is entered.</p>
				<p><b>NOTE:</b>	If a Pending recommendation changes to Accepted or Rejected, this constitutes a new intervention and a new new intervention should be added.</p>
			</p>
		</div>
		<div id="intervention-code-help-dialog-message" title="Intervention Code">
			<p>
				The intervention code associated with the intervention.
			</p>
			<p>
				<p>If user selects any values that are risk mitigation (e.g. contains "(r)", then the recommended drug box will be disabled and any information in the recommended drug box will not be saved.</p>
			</p>
		</div>
		<div id="drug-frequency-help-dialog-message" title="Drug Frequency">
			<p>Drug Frequency Indicates how often a drug is taken.</p>
			<p>Select from a list of predefined values for the Drug Frequency.</p>
			<p>If 'Daily' is selected, the user may define the number for the doses per day.</p>
			<p>Otherwise, the value for Doses Per Day stays 1 fordrugs not taken on a daily basis.</p>
		</div>
		<div id="cost-per-day-help-dialog-message" title="Cost Per Day">
			<p>Represents the Hospital Acquisition Cost.</p>
			<p>This is calculated by multiplying Unit Cost by Drug Frequency by Doses Per Day.</p>
		</div>
		<div id="risk-mitigation-help-dialog-message" title="Risk Mitigation">
			<p>Any Intervention Code ending with (r) indicates a Risk Mitigation Code.</p>
			<p>The recommended drug option is not used with these codes.</p>
		</div>
		<div id="days-of-tx-help-dialog-message" title="Days of Tx">
			<p>Number estimated of treatment days.</p>
		</div>
		<div id="current-tx-day-help-dialog-message" title="Current Tx Day">
			<p>Current day in therapy course.  If intervention occurs before therapy begins, then current day of therapy is zero.</p>
		</div>
		<div id="days-remaining-help-dialog-message" title="Days Remaining">
			<p><b>Calculated value:</b>  <i>Days of Tx</i> minus <i>Current Tx Day</i>.</p>
		</div>
	<?php //End Help Messages?>
	
	<?php //<p><br />Page rendered in {elapsed_time} seconds</p> ?>
	
	</body>
</html>